package solved;
import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.FileReader;
import java.io.FileWriter;
import java.io.IOException;
import java.io.PrintWriter;

/*
 ID:	liluyan1
 LANG:	JAVA
 TASK:	palsquare
 */
public class palsquare {
	public static void main(String[] args) throws IOException {
		BufferedReader f = new BufferedReader(new FileReader("palsquare.in"));
		int B = Integer.parseInt(f.readLine());
		
		PrintWriter out = new PrintWriter(new BufferedWriter(new FileWriter(
				"palsquare.out")));
		for (int i=1; i<=300; i++) {
			String square = Integer.toString(i*i, B).toUpperCase();
			if (isPalindrome(square)) out.println(Integer.toString(i, B).toUpperCase() + " " + square);
		}
		out.close();
		System.exit(0);
	}
	
	public static boolean isPalindrome(String s) {
		int N = s.length();
		for (int i=0; i<s.length()/2; i++) {
			if (s.charAt(i) != s.charAt(N-i-1)) return false;
		}
		return true;
	}
}
